var files = require('./files');
var url = require('url');
var querystring = require('querystring');

module.exports = {
	home:function(res){
		res.writeHead(200,{'Content-Type':'text/html;charset=utf-8'});
		files.readFile('../../front/index.html',res);
	},
	login:function(res,req){
		res.writeHead(200,{'Content-Type':'text/html;charset=utf-8'});
		files.readFile('../../front/login.html',res);
	},
	loginAction:function(res,req){
		// 处理post请求
		var post = "";
		//前台表单提交了，on事件监控data就会触发
		req.on('data',function(chunk){
			post += chunk;
		});
		// req在end的时候触发事件
		// 需要引入querystring模块进行解析操作
		req.on('end',function(){
			var urlObject = querystring.parse(post);
			console.log(urlObject);
		})
	},
	reg:function(res){
		res.writeHead(200,{'Content-Type':'text/html;charset=utf-8'});
		files.readFile('../../front/reg.html',res);
	}
}
